//
//  HMSpringFlowsTVLookCell.m
//  springFlowers
//
//  Created by qu on 2017/1/4.
//  Copyright © 2017年 Apple. All rights reserved.
//

#import "HMSpringFlowsTVLookCell.h"
#import "HMSpringFlowersViewModel.h"
@interface HMSpringFlowsTVLookCell ()
@property (weak, nonatomic) IBOutlet UILabel *read_countLabel;
@property (weak, nonatomic) IBOutlet UILabel *item_titleLabel;
@property (weak, nonatomic) IBOutlet UILabel *add_timeLabel;
@property (weak, nonatomic) IBOutlet UILabel *like_countLabel;
@property (weak, nonatomic) IBOutlet UIImageView *item_image_urlImageView;
@property (weak, nonatomic) IBOutlet UILabel *item_introduceLabel;



@end
@implementation HMSpringFlowsTVLookCell

- (void)awakeFromNib {
    [super awakeFromNib];
}

- (void)setSfViewModel:(HMSpringFlowersViewModel *)sfViewModel {
    
    _sfViewModel = sfViewModel;
    self.read_countLabel.text = [NSString stringWithFormat:@"%zd人读过",sfViewModel.read_count];
    self.like_countLabel.text = [NSString stringWithFormat:@"%zd",sfViewModel.like_count];
    self.item_titleLabel.text = sfViewModel.item_title;
    self.item_introduceLabel.text = sfViewModel.item_introduce;
    [self.item_image_urlImageView sd_setImageWithURL:[NSURL URLWithString:sfViewModel.item_image_url]];
    self.item_image_urlImageView.clipsToBounds = YES;
    self.add_timeLabel.text = [self getAddTimeForDate:sfViewModel.add_time];
    
}

- (NSString *)getAddTimeForDate:(NSInteger)addTime {
    
    NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
    formatter.dateFormat = @"M月dd日";
    NSDate *date = [NSDate dateWithTimeIntervalSince1970:addTime];
    return [formatter stringFromDate:date];
}
- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated {
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
//    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
